/*
 * Created by Lettle on 2022/4/15.
 * QQ: 1071445082
 * github: https://github.com/Python-Lettle
 * gitee : https://gitee.com/lettle/
 */
/**
//    ︱￣￣￣￣￣￣￣￣￣￣︱
//    ︱     MS-DOS     ︱
//    ︱    MZ  头部     ︱--------------> 64 byte
//    ︱                ︱
//    ︱ ￣ ￣ ￣ ￣ ￣ ￣︱
//    ︱     MS-DOS     ︱
//    ︱ 实模式残余程序   ︱--------------> 112 byte
//    ︱                ︱
//    ︱￣￣￣￣￣￣￣￣￣︱
//    ︱    PE文件标志   ︱--------------> 4 byte
//    ︱                ︱
//    ︱￣ ￣ ￣ ￣ ￣ ￣ ︱
//    ︱     PE文件头    ︱--------------> 20 byte
//    ︱                ︱
//    ︱￣ ￣ ￣ ￣ ￣ ￣ ︱
//    ︱   PE文件可选头  ︱--------------> 224 byte
//    ︱               ︱
//    ︱￣￣￣￣￣￣￣￣￣︱
//    ︱     各段头部    ︱--------------> n * 40 byte
//    ︱                ︱
//     ￣￣￣￣￣￣￣￣￣
 */
#ifndef COCKTAIL_CODEGEN_H
#define COCKTAIL_CODEGEN_H

#define BYTE unsigned char

typedef struct WORD {
    BYTE low;
    BYTE high;
}WORD;

typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header
    WORD   e_magic;                     // Magic number
    WORD   e_cblp;                      // Bytes on last page of file
    WORD   e_cp;                        // Pages in file
    WORD   e_crlc;                      // Relocations
    WORD   e_cparhdr;                   // Size of header in paragraphs
    WORD   e_minalloc;                  // Minimum extra paragraphs needed
    WORD   e_maxalloc;                  // Maximum extra paragraphs needed
    WORD   e_ss;                        // Initial (relative) SS value
    WORD   e_sp;                        // Initial SP value
    WORD   e_csum;                      // Checksum
    WORD   e_ip;                        // Initial IP value
    WORD   e_cs;                        // Initial (relative) CS value
    WORD   e_lfarlc;                    // File address of relocation table
    WORD   e_ovno;                      // Overlay number
    WORD   e_res[4];                    // Reserved words
    WORD   e_oemid;                     // OEM identifier (for e_oeminfo)
    WORD   e_oeminfo;                   // OEM information; e_oemid specific
    WORD   e_res2[10];                  // Reserved words
    LONG   e_lfanew;                    // File address of new exe header
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;

//typedef struct _IMAGE_NT_HEADERS {
//    DWORD Signature;
//    IMAGE_FILE_HEADER FileHeader;
//    IMAGE_OPTIONAL_HEADER32 OptionalHeader;
//} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;

#endif //COCKTAIL_CODEGEN_H
